#ifndef BLOCKLIST_H
#define BLOCKLIST_H

#include "thrust/host_vector.h"
#include "thrust/device_vector.h"
#include "Matrix.h"
#include "BitStream.h"

#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

class BlockList
{
public:
	BlockList() 
	{
		_data = NULL;
		_size = 0;
		_matrixSize = 0;
		_columnLength = 0;
		_columns = 0;
		_rows = 0;
		_dataHeight = 0;
		_dataWidth = 0;
	}
	~BlockList() {}
	__host__ __device__ uint8_t* data() const { return _data; }
	__host__ __device__ int size() {return _size;}
	__host__ __device__ uint8_t getPixel(int row, int column);
	__host__ __device__ void set(int i, Matrix& block);
	__device__ void setDevice(int i, Matrix& block);
	__host__ __device__ int getColumns() const { return _columns; }
	__host__ __device__ void setColumns(int val) { _columns = val; }
	__host__ __device__ int getRows() const { return _rows; }
	__host__ __device__ void setRows(int val) { _rows = val; }
	__host__ __device__ size_t getMatrixSize() const { return _matrixSize; }
	__host__ __device__ int getDataHeight() const { return _dataHeight; }
	__host__ __device__ int getDataWidth() const { return _dataWidth; }
	__host__ __device__ size_t getColumnLength() const { return _columnLength; }

    __host__ __device__ void clear();

    __host__ __device__ void initialize(uint8_t *buff, int width, int height, int totalBlocks, int columnAndRowSize);

    __host__ __device__ Matrix getBlockAtCoord(int x, int y);

	__host__ __device__ Matrix operator[]( const int i );

	__host__ void cloneToDevice(uint8_t** dest);

	__host__ void cloneToHost(uint8_t* src);

	//__host__ void testCUData();

private:
	uint8_t* _data;
	size_t _size;
	size_t _matrixSize;

	size_t _columnLength;
	int _rows;
	int _columns;
	int _dataWidth;
	int _dataHeight;
    void initBlockList(int totalBlocks, int columnAndRowSize);
};

#endif // BLOCKLIST_H
